/*
 *  $Id: CriticalStrike.cs 975 2009-12-16 17:13:22Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Affects {
    /// <summary>
    /// Эффект: критический удар
    /// Параметры: шанс X и бонус Y
    /// При выпадении X или выше урон увеличивается на Y. 
    /// </summary>
    public class CriticalStrike: Affect {
        private static readonly Languages.Phrase Try = new Languages.Phrase("affect.critical_strike.try");

        public readonly int Chance, Bonus;

        public CriticalStrike(int chance, int bonus) {
            Chance = chance;
            Bonus = bonus;
        }

        public override string Id {
            get { return "critical_strike"; }
        }
        public override string NameText {
            get {  return Name.GetText(Chance, Bonus); }
        }

        public override int BaseWeight {
            get { return (7-Chance)*15 + Bonus*10; }
        }

        public override AffectIcon Icon {
            get { return AffectIcon.CriticalStrike; }
        }

        public override Affect Clone() {
            return new CriticalStrike(Chance, Bonus);
        }

        public override void SetAffect() {
            base.SetAffect();
            LocalSummary.AddCriticalStrike(this);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            LocalSummary.RemoveCriticalStrike(this);
        }

        public int GetCritical() {
            int dice = Game.Current.GetDiceNextValue();
            bool success = dice >= Chance;
            Game.Current.Log.Add(Try, dice, Resources.Game.Success(success));
            return success ? Bonus : 0;
        }
    }
}